import axios from 'axios'

const ERR_OK = 200
const baseURL = process.env.NODE_ENV === 'production' ? 'https://netease-cloud-fan-music-api.vercel.app/' : 'https://netease-cloud-fan-music-api.vercel.app/'

axios.defaults.baseURL = baseURL

export function get(url, params) {
  return axios.get(url, {
    params
  }).then((res) => {
    // console.log(res);
    const serverData = res.data
    if (serverData.code === ERR_OK) {
      return serverData
    }
  }).catch(e => {
    console.log(e);
  }) 
}